from django.contrib import admin
from .models import Book,Author

# Register your models here.


class BookManager(admin.ModelAdmin):
    #列表页显示哪些字段的列
    list_display = ['id', 'title', 'pub', 'price']
    #控制list_display中的字段，哪些可以链接到修改页
    list_display_links = ['title']
    #添加过滤器
    list_filter = ['pub']
    #添加搜索框
    search_fields = ['title']
    #添加可在列表页编辑的字段
    list_editable = ['price']

admin.site.register(Book,BookManager)

class AuthorManager(admin.ModelAdmin):
    #列表页显示哪些字段的列
    list_display = ['id', 'name', 'age', 'email']

admin.site.register(Author,AuthorManager)